package com.nttuan.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.nttuan.flows.SysContactListener;
import com.nttuan.model.entity.Contact;
import com.nttuan.model.entity.User;
import com.nttuan.mycalender.R;

import java.util.List;

/**
 * Created by TuanNT on 11/6/2014.
 */
public class FindUserAdapter extends BaseAdapter {

    private LayoutInflater inflater;
    private List<User> list;
    private Context context;

    public FindUserAdapter(Context context, List<User> list) {
        this.context = context;
        this.inflater = LayoutInflater.from(context);
        this.list = list;
    }
    public List<User> getList() {
        return list;
    }

    public void setList(List<User> list) {
        this.list = list;
    }

    @Override
    public int getCount() {
        if(list == null)
            return  0;
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return i;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
        final ViewHoller holler;
        if (view == null) {
            holler = new ViewHoller();
            view = inflater.inflate(R.layout.item_find_user, null);
            holler.name = (TextView) view.findViewById(R.id.textFindUserItemName);
            holler.email = (TextView) view.findViewById(R.id.textFindUserItemEmail);
            view.setTag(holler);
        } else
            holler = (ViewHoller) view.getTag();
        User user = list.get(i);
        holler.name.setText(user.getUserName());
        holler.email.setText(user.getEmail());

        return view;
    }
    class ViewHoller {
        TextView name;
        TextView email;

    }
}
